home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / BaudBandit.adf / REXX / Answer.baud < prev    next >
Text File  |  1992-02-17  |  6KB  |  262 lines

  1. /*
  2.   BaudBandit V1.30 remote server      Needs ARexx 1.10
  3.  
  4.   'F10 \mAnswer local' for local login.
  5. */
  6.  
  7. arg option
  8. signal on break_c
  9. Options Results
  10.  
  11. Remote U ; UPath=Result
  12. Remote D ; DPath=Result
  13. Remote W ; WelcomeFile=Result
  14. Remote P ; Password=Upper(Result)
  15. Remote S ; SPassword=Upper(Result)
  16.  
  17. if Right(UPath,1)=':' then
  18.     MsgFile=UPath'BBMsgs'
  19. else    MsgFile=UPath'/BBMsgs'
  20.  
  21. maxidle=3*60        /* Idle time = 3 minutes */
  22.  
  23. /** remote login **/
  24.  
  25. if(option='') then do
  26.     Send 'ATA\r'
  27.     Timeout 20
  28.     Wait 'CONNECT'        /* wait 20 seconds for connect */
  29.     if rc~=0 then exit    /* timed out? */
  30.     call delay 120
  31.     Remote ON
  32. end
  33. else do /* local */
  34.     Set H
  35.     Quiet on
  36. end
  37.  
  38. Timeout maxidle         /* max idle time at prompts */
  39.  
  40.  
  41. /** Welcome message */
  42. address command 'Type' WelcomeFile
  43.  
  44. tries=0
  45. options prompt 'Password: '
  46. say
  47. do forever
  48.     pull pass
  49.     if(pass=password | pass=spassword) then break;    /* correct password */
  50.     else do
  51.         tries=tries+1
  52.         if(tries=3) then do        /* 3 tries, hang up */
  53.             say 'Access terminated.'
  54.             Remote OFF
  55.             Quiet off
  56.             Set F
  57.             Send '\ah'
  58.             exit
  59.          end
  60.         options prompt 'Incorrect.  Password: ' /* ask again */
  61.      end
  62.  end
  63. hilevel=0
  64. if(pass=spassword) then hilevel=1
  65.  
  66. Status 'D'
  67. startdir=result
  68. call pragma('D',DPath)
  69. directory=pragma('D')
  70. Data directory
  71.  
  72. /* Get current protocol */
  73. Status Trans
  74. protocol = RESULT
  75.  
  76. /*-------------------------- MAIN --------------------------------------------*/
  77.  
  78.  
  79. do while(opt~='G')
  80.     go=0
  81.     do while(~go)
  82.             say
  83.             say '                 ___________'
  84.             say '     ___________/ Main Menu \__________'
  85.             say '    |                                  |'
  86.             say '    |  [L]ist        [P]rotocol        |'
  87.             say '    |  [D]ownload    [U]pload          |'
  88. if hilevel~=0 then    say '    |  [S]hell                         |'
  89.             say '    |  [M]essage     [R]ead text file  |'
  90.             say '    |  [G]oodbye     [H]elp            |'
  91.             MSG '    |  [\] Chat                        |'
  92.             say '    |__________________________________|'
  93.             say
  94.  
  95.         options prompt time(c)'> '
  96.         parse upper pull string' 'arg
  97.         opt=left(string,1)
  98.  
  99.         go=1    /* check for access */
  100.         if(hilevel=0) then if(opt='S') then go=0
  101.     end
  102.  
  103.     options prompt 'Filename: '
  104.     select
  105.         when(opt='L') then call list();
  106.         when(opt='P') then call chpro();
  107.         when(opt='D') then call dload();
  108.         when(opt='U') then call uload();
  109.         when(opt='H') then call help();
  110.         when(opt='R') then call read();
  111.         when(opt='M') then call edit();
  112.         when(opt='S') then call shell();
  113.         when(opt='\') then call chat();
  114.         otherwise call page();
  115.     end
  116. end
  117.  
  118. say 'Goodbye, thank you for calling.'
  119.  
  120. if(option='') then do
  121.     Remote off
  122.     dcd
  123.     if(rc~=0) then Send '\ah'
  124. end
  125.  
  126. Data startdir
  127. Quiet off
  128. Set f
  129. exit
  130.  
  131. /*------------------------- FUNCTIONS ---------------------------------------*/
  132.  
  133. help:    say
  134.     say ' Command summary:'
  135.     say ' L    List files in directory'
  136.     say ' P    Protocol menu.  Or give option at main prompt (P Z)'
  137.     say ' U    Upload file.        Optional ( U filename )'
  138.     say ' D    Download file.      Optional ( D filename )'
  139.  if(hilevel~=0) then
  140.     say ' S    Enter command shell.  CD will change D/L dir.'
  141.  
  142.     say ' R    Read text file.     Optional ( R filename )'
  143.     MSG ' \    Enter chat mode.  \ on a blank line to end.'
  144.     say ' G    Goodbye. (Hangup!)'
  145.     say
  146.     options prompt 'Continue:'
  147.     pull arg
  148.     return;
  149.  
  150. shell:    say
  151.     Say 'Dropping to DOS.  Type EXIT to end.'
  152.     do while(upper(opt)~='EXIT')
  153.         options prompt '1B'x'[33m'pragma('D')'>'||'1B'x'[0m'
  154.         parse pull opt' 'arg
  155.         if(upper(opt)='CD') then do
  156.             call pragma('D',arg)
  157.             directory=pragma('D')
  158.             Data directory        /* Keeps BB in sync w/shell */
  159.             iterate
  160.         end
  161.         if exists(opt)~=0 then do    /* Implicit CD */
  162.             if left(statef(opt),3)='DIR' then do
  163.                 call pragma('D',opt)
  164.                 directory=pragma('D')
  165.                 Data directory
  166.                 iterate
  167.             end
  168.         end
  169.         if(opt~='' & upper(opt)~='EXIT') then
  170.             address command opt '<* >*' arg
  171.      end
  172.     return
  173.  
  174. uload:    if(arg='') then pull arg    /* no filename given */
  175.     if(arg~='') then do        /* check for filename */
  176.         Say 'Starting' protocol 'Upload'
  177.         call pragma('D',UPath)
  178.         directory=pragma('D')
  179.         Data directory
  180.         DownLoad arg
  181.         call pragma('D',DPath)
  182.         directory=pragma('D')
  183.         Data directory
  184.     end
  185.     return
  186.  
  187. dload:    if(arg='') then pull arg    /* no filename given */
  188.     if(arg~='') then do        /* check for filename */
  189.         Say 'Starting' protocol 'Download'
  190.         UpLoad arg
  191.     end
  192.     return
  193.  
  194. edit:    if ~Open(f,MsgFile,'A') then
  195.         if ~Open(f,MsgFile,'W') then do
  196.             say 'Unable to open message file.'
  197.             return
  198.         end
  199.     Say
  200.     Say 'Enter your message.  [Return] on a blank line to end.'
  201.     do while(line~='')
  202.         options prompt ': '
  203.         parse pull line
  204.         call writeln(f,line)
  205.     end
  206.     call writeln(f,'')
  207.     call Close(f)
  208.     Say 'Message saved.'
  209.     return
  210.  
  211. chpro:    if(arg='') then do    /* show protocol menu */
  212.         say
  213.         say '[W]- WXModem'
  214.         say '[X]- XModem-CRC'
  215.         say '[K]- XModem-1K'
  216.         say '[Y]- YModem'
  217.         say '[G]- YModem-G'
  218.         say '[Z]- ZModem'
  219.         say '[A]- ZModem (Upload at Menus)'
  220.         say
  221.         options prompt protocol '> '
  222.         pull arg
  223.      end
  224.     Set arg
  225.     Status Transfer
  226.     protocol = RESULT
  227.     say protocol
  228.     return
  229.  
  230. read:    if(arg=='') then pull arg    /* no filename given */
  231.     say
  232.     if(arg~='') then address command 'CD' directory'0A'x 'Type >* <*' arg
  233.     options prompt 'Continue:'
  234.     pull arg
  235.     return
  236.  
  237. list:    address command 'list >* <*' directory
  238.     options prompt 'Continue:'
  239.     pull arg
  240.     return
  241.  
  242. chat:    options prompt ''
  243.     string=''
  244.     do while(string~='\')
  245.         pull string
  246.     end
  247.     return
  248.  
  249. page:    Beep 320;Beep 390;Beep 360;Beep 500;Beep 240
  250.     return
  251.  
  252. break_c:
  253.     Say 'Timeout/Carrier loss -- Disconnecting.'
  254.     Remote OFF
  255.     dcd
  256.     if(rc~=0) then Send '\ah'
  257.     Data startdir
  258.     Quiet off
  259.     Set F
  260.     exit
  261.  
  262.